﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace z.r {
	/// <summary>
	/// Interaction logic for ReportChoseDate.xaml
	/// </summary>
	public partial class ReportChoseDate : Window {
		public ReportChoseDate() {
			InitializeComponent();
		}
		ReportViewer r;
		private void btnDate_Click(object sender, RoutedEventArgs e) {
			if (calendar.SelectedDates.Count > 1) {
				r=new ReportViewer("dates",calendar.SelectedDates.First(), calendar.SelectedDates.Last().AddDays(1));
			} else if (calendar.SelectedDate!=null) {
				r = new ReportViewer("dates", calendar.SelectedDate.Value, calendar.SelectedDate.Value.AddDays(1));
			} else {
				r = new ReportViewer("dates", DateTime.Now.Date, DateTime.Now.Date.AddDays(1));
			}
			r.ShowDialog();
		}

		private void btnMonth_Click(object sender, RoutedEventArgs e) {
			if (calendar.SelectedDate != null) {
				r = new ReportViewer("month", calendar.SelectedDate.Value);
			} else {
				r = new ReportViewer("month", DateTime.Now.Date);
			}
			r.ShowDialog();
		}

		private void btnYear_Click(object sender, RoutedEventArgs e) {
			if (calendar.SelectedDate != null) {
				r = new ReportViewer("year", calendar.SelectedDate.Value);
			} else {
				r = new ReportViewer("year", DateTime.Now.Date);
			}
			r.ShowDialog();
		}
	}
}
